package com.cn.jx.manager.dao;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.cn.jx.manager.po.Contact;

/**
 * <p>ContactRepository 联系人mapper层操作数据库的接口
 * <p>实现<{@link BaseRepository <tt>公用</tt>}}
 * 
 * @author <h1>jiangxu2  2019年11月21日</h1>
 * @version v1.11.20.2019
 * @since 1.0
 * 
 */
public interface ContactRepository extends JpaRepository<Contact,String>,JpaSpecificationExecutor<Contact>{
	
	/**<p>定义HQL根据id查询对象{@link Contact} */
	@Query("from Contact  where id=:pid and delFlg=0 and validFlg=1 ")
	public Contact findEntityByPkid(@Param(value = "pid") String pid);
	
	/**<p>定义HQL查询标记删除{@link Contact} */
	@Modifying
	@Query("update Contact c set c.delFlg=1,c.validFlg=0 where c.id=:pid ")
	public void deleteEntityById(@Param(value="pid") String pid);
	
	/**<p>定义HQL找回 恢复删除{@link Contact} */
	@Modifying
	@Query("update Contact c set c.delFlg=0,c.validFlg=1 where c.id=:pid ")
	public void recoverEntityById(@Param(value="pid") String pid);
}
